<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of GuestController
 *
 * @author vampired
 */
class GuestController extends Zend_Controller_Action {

    public function indexAction() {

           $form = new Golib_Form_Guest();

        $this->view->form = $form;
        if ($this->_request->isPost() && $form->isValid($_POST)) {

            $guest = new Guestbook();
            $guest->name = $_POST['name'];
            $guest->email = $_POST['email'];
            $guest->comment = $_POST['message'];
            $guest->date =date("Y-m-j h:i:s");
            $guest->approved=0;
            $saved=$guest->trySave();      
            //to add some message or something
            $this->view->saved=$saved;
            $this->_redirect($_SERVER['HTTP_REFERER']);
        }
    
        $this->view->posts=GuestbookTable::getPosts();
    }

}
